- default_branch_name = @project.default_branch_or_main
- escaped_default_branch_name = default_branch_name.shellescape

- git_push_target = ''
- if protocol == 'ssh'
  - ssh_doc = link_to('', help_page_path('user/ssh.md'), target: '_blank', rel: 'noopener noreferrer')
  %p.gl-mt-2= safe_format(_('%{link}How to use SSH keys%{link_end}?'), tag_pair(ssh_doc, :link, :link_end))
  - git_push_target = content_tag(:span, ssh_clone_url_to_repo(@project), class: 'js-clone')
- if protocol == 'https'
  - git_push_target = content_tag(:span, http_clone_url_to_repo(@project), class: 'js-clone')
- if protocol == 'kerberos'
  - git_push_target = content_tag(:span, @project.kerberos_url_to_repo, class: 'js-clone')

%h4= _('Create a new repository')
%pre.code.js-syntax-highlight
  :preserve
    git clone #{git_push_target}
    cd #{h @project.path}
    git switch --create #{h escaped_default_branch_name}
    touch README.md
    git add README.md
    git commit -m "add README"
  - if @project.can_current_user_push_to_default_branch?
    %span><
      git push --set-upstream origin #{h escaped_default_branch_name}
%h4= _('Push an existing folder')
%h5= _('Go to your folder')
%pre.code.js-syntax-highlight
  :preserve
    cd existing_folder
%h5= _('Configure the Git repository')
%pre.code.js-syntax-highlight
  :preserve
    git init --initial-branch=#{h escaped_default_branch_name} --object-format=#{h @project.repository_object_format}
    git remote add origin #{git_push_target}
    git add .
    git commit -m "Initial commit"
  - if @project.can_current_user_push_to_default_branch?
    %span><
      git push --set-upstream origin #{h escaped_default_branch_name}

%h4= _('Push an existing Git repository')
%h5= _('Go to your repository')
%pre.code.js-syntax-highlight
  :preserve
    cd existing_repo
%h5= _('Configure the Git repository')
%pre.code.js-syntax-highlight
  :preserve
    git remote rename origin old-origin
    git remote add origin #{git_push_target}
  - if @project.can_current_user_push_to_default_branch?
    %span><
      git push --set-upstream origin --all
      git push --set-upstream origin --tags
